import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Carousel } from '../../app/model/carousel';
import { NewsProvider } from '../../providers/news/news';
import { CarouseldetailPage } from '../carouseldetail/carouseldetail';
import { News } from '../../app/model/news';
import { NewsdetailPage } from '../newsdetail/newsdetail';
import { ConfigProvider } from '../../providers/config/config';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

   cl:Array<Carousel>
   nl:Array<News>
   PICHOST:string;

  constructor(public navCtrl: NavController,
    private newsService:NewsProvider
    ,private configservice:ConfigProvider) {

      this.PICHOST=configservice.HOST+"/public/"


      this.initCarouselList();
      this.initNewsList();
  }


   initCarouselList(){
    this.cl=new Array();

    this.newsService.getCarouselList()
    .then((data:any)=>{
      this.cl=data;
       


    })
   


   }

   initNewsList(){
    this.nl=new Array();
    this.newsService.getNewsList()
    .then((data:any)=>{
      this.nl=data;
    })



   }




   goToCarouselDetail(carousel:Carousel){


    this.navCtrl.push(CarouseldetailPage,{"carousel":carousel});




   }


   goToNewsDetail(news:News){

     this.navCtrl.push(NewsdetailPage,{"news":news})

   }




}
